
var MEETING_CODES = {
   O: "OPEN",
   C: "CLOSED", 
   B: "BEGINNERS",
   S: "STEPS",
   T: "TRADITIONS",
   BB: "BIG BOOK",
   D: "DISCUSSION",
   OD: "OPEN DISCUSSION",
   CD: "CLOSED DISCUSSION",
   OS: "OPEN SPEAKER",
   YP: "YOUNG PEOPLE",
   G: "GAY / ALL WELCOME",
   HA: "HANDICAP ACCESSIBLE",
   M: "MEN'S MEETING",
   W: "WOMEN'S MEETING",
   DF: "SIGN LANGUAGE INTERPRETED",
   CP: "COUPLES",
   LM: "LUNCH MEETING",
   SP: "SPANISH",
   GV: "GRAPEVINE",
   A: "AL-ANON",
   RU: "RUSSIAN"
};

function viewCart() {
  document._cart.submit();
}

function clearSimpleSearch() {
  var elem = $("#searchAddress").get()[0];
  elem.value = "";
}

function fillSimpleSearch() {
  var elem = $("#searchAddress").get()[0];
  if (elem.value == "") {
    elem.value = "CITY, ZIP";
  }
}

function onSimpleSearch() {
  var elem = $("#searchAddress").get()[0];
  if (elem.value == "CITY, ZIP") {
    elem.value = "";
  }
}

function codesToDescs(codes) {
   var result = "";
   var values = new Array();
   values = codes.split(",");
   values.reverse(); 

   for (var i in values) {
     if (result !== "") {
       result = MEETING_CODES[values[i]] + ", " + result;
     } else {
       result = MEETING_CODES[values[i]];
     }
   }
   
   return result;
}

function translateCodes(str,id) {
   var result = codesToDescs(str);
   document.getElementById(id).title = result;
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}